package qn.easywechat.web.controller;

import com.alibaba.druid.support.json.JSONUtils;
import com.qn.web.qnwebbase.common.vo.UserInfo;
import com.qn.web.qnwebbase.service.ILoginService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import qn.easywechat.web.vo.request.GetSysConfigRequest;
import qn.easywechat.web.vo.response.SysConfigVo;

import javax.annotation.Resource;
import java.util.UUID;

@RestController
@RequestMapping("index")
public class IndexController {

    @Value("${qn.easywechat.env}")
    private String env;

    @Resource
    ILoginService loginService;

    @ApiOperation(value = "获取系统信息")
    @RequestMapping(value = "/sysinfo", method = RequestMethod.POST)
    @ApiImplicitParam(name = "input", value = "测试输入", required = true)
    public String sysinfo(@RequestBody String input) {
        return env + "---" + System.currentTimeMillis() + ":" + input;
    }

    @ApiOperation(value = "登陆信息")
    @RequestMapping(value = "/islogin", method = RequestMethod.GET)
    public String isLogin(String ulId) {
        UserInfo userInfo =new UserInfo();
        userInfo.setRoleCode("admin");
        userInfo.setUlId(UUID.randomUUID().toString());
        loginService.login(userInfo);
        UserInfo getUserInfo = loginService.getUserLoginInfo(userInfo.getUlId());
        return JSONUtils.toJSONString(getUserInfo);
    }

}
